<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport"
	content="width=device-width, user-scalable=no, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0" />
<title>Insert title here</title>
</head>
<body>
		<div class="login-logo">
			<b>入驻申请</b>
		</div>
		<form action="apply/submits" method="POST"
			enctype="multipart/form-data">
			<input type="text" name="username" placeholder="申请人姓名"><br />
			<input type="text" name="mobile" placeholder="手机号码"><br /> <input
				type="file" name="file" placeholder="上传营业执照"></br> <input
				type="file" name="file" placeholder="上传身份证正面照"><br /> <input
				type="file" name="file" placeholder="上传身份证反面照"><br /> <input
				type="submit" value="提交">
		</form>

		<div id="rrapp">
		    <input type="text" v-model="mobile" placeholder="请输入手机号"><br>
		    <input type="text" v-model="validcode" placeholder="请输入验证码"><button @click="getValidCode">获取验证码</button><br>
			<button id="login" @click="login">登陆</button>
			<br>
			<input type="text" v-model="name" placeholder="请输入收款员姓名"><br>
			<input type="text" v-model="cmobile" placeholder="请输入收款员手机号"><br>
			<button id="addcashier" @click="addCashier">添加收款员</button><br>
			<div >
			  <li v-for="data in list" v-on:click="deleteCashiers(data)" >
			     <div>{{data.name}}</div>
			     <div>{{data.mobilephone}}</div>
			  </li>
			</div>
			<button id="viewCashier" @click="viewCashiers">查看所有收款员</button><br>
			<button @click="viewMerInfo">查看商户基本信息</button><br>
			<button @click="viewQRCode">查看收款码</button><br>
			<button @click="test">test</button>
		</div>
		<script src="statics/libs/jquery.min.js"></script>
		<script src="statics/libs/vue.min.js"></script>
		<script src="statics/libs/bootstrap.min.js"></script>
		<script src="statics/libs/jquery.slimscroll.min.js"></script>
		<script src="statics/libs/fastclick.min.js"></script>
		<script src="statics/libs/app.js"></script>
		<script type="text/javascript"
			src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
		<script>
		  var vm = new Vue({
				el:'#rrapp',
				data:{
					mobile: '',
					validcode:'',
					name:'',
					cmobile:'',
					list:[],
				},
				methods: {
					test:function(event){
						$.ajax({
							type:"POST",
							url:"submit",
							data:{info:1},
							dataType:"json",
							success:function(result){
								alert(result.code);
							}
						});
					},
					viewQRCode:function(event){
						location.href="viewQRCode";
					},
					viewMerInfo:function(event){
						location.href="viewMerInfo";
					},
					deleteCashiers:function(data){
						var d="mobile="+data.mobilephone;
						$.ajax({
							type:"POST",
							url:"delCashier",
							data:d,
							dataType:"json",
							success:function(result){
								alert(result.code);
							}
						});
					},
					viewCashiers:function(event){
						var _this=this;
						$.ajax({
							type:"POST",
							url:"viewCashierList",
							dataType:"json",
							success:function(result){
								alert(result.list);
								_this.list = result.list;
							}
						});
					},
					getValidCode:function(event){
						var data="mobile="+vm.mobile;
						if(vm.mobile.trim().length==0){
							alert("请填写手机号码");
							return;
						}
						$.ajax({
							type:"POST",
							url:"getValidCode",
							data:data,
							dataType:"json",
							success:function(result){
								if(result.code==0){
									alert("短信验证码已发送，请注意查收。");
								}
							}
						})
					},
					login: function (event) {
						var data = "mobile="+vm.mobile+"&validcode="+vm.validcode;
						alert(data)
						$.ajax({
							type: "POST",
						    url: "sureLogin",
						    data: data,
						    dataType: "json",
						    success: function(result){
								if(result.code == 0){//登录成功
									alert("登录成功");
								}else{
									alert("登录失败");
								}
							}
						});
					},
					addCashier:function(event){
						var data="name="+vm.name+"&mobile="+vm.cmobile;
						$.ajax({
							type:"POST",
							url:"addCashier",
							data:data,
							dataType:"json",
							success:function(result){
								alert(result.code);
							}
						});
					}
				}
			});
		</script>
</body>
</html>
